/**
 * 所有版权归 广西梧州 陈锦韬 所有
 *
 * @Title: MainService
 * @Package com.rx.service
 * @Description: 主要服务
 * @author: 陈锦韬
 * @date: 2022/2/26
 * @version V1.0
 * @Copyright: 2022 陈锦韬  All rights reserved.
 */
package com.rx.service;

import com.rx.bean.ReadProperties;
import com.rx.bean.RxMainConfigBean;
import com.rx.core.base.RxBaseConstant;
import com.rx.core.service.RxBaseAbstractService;
import com.rx.core.util.RxUtil;
import com.rx.vo.MainHelloVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author: CHENJINTAO170
 * @Description: 主要服务
 * @date: 2022/2/26
 */
@Service
@Slf4j
public class MainService extends RxBaseAbstractService {

    @Autowired
    RxMainConfigBean rxMainConfigBean;

    public MainHelloVo hello(MainHelloVo mainService){

        SimpleDateFormat formatter = new SimpleDateFormat(RxBaseConstant.DATE_FORMAT_DATETIME.trim());
        String dateString = formatter.format(new Date()).trim();
        String md5 = RxUtil.EncryptUtil.toMD5(dateString.substring(0,16));
        if(!md5.equalsIgnoreCase(mainService.getSequences())){
           // return mainService;
        }
        // 以后改成数据库
        ReadProperties.loadConfig(rxMainConfigBean);

        mainService.setAdFileName(rxMainConfigBean.getAdFileName());
        mainService.setAppVersion(rxMainConfigBean.getAppVersion());
        mainService.setAdShow(rxMainConfigBean.getAdShow());
        mainService.setAppApk(rxMainConfigBean.getAppApk());
        return  mainService;
    }
}
